package cn.getech.data.development.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 表信息
 * </p>
 *
 * @author zenith
 * @since 2018-09-19
 */
@Data
@TableName("bdp_table_info")
@ApiModel(description = "表信息")
public class TableInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 数据库名称
     */
    @NotBlank(message = "数据库名称不可为空")
    @TableField("db_name")
    private String dbName;
    /**
     * 表名称
     */
    @NotBlank(message = "表名称不可为空")
    @TableField("table_name")
    private String tableName;

    /**
     * 表别名
     */
    @NotBlank(message = "表别名不可为空")
    @TableField("table_alias")
    private String tableAlias;

    /**
     * 格式
     */
    @NotBlank(message = "格式不可为空")
    @TableField("format")
    private String format;

    /**
     *分隔符Id
     */
    @TableField("delimit_id")
    private Integer delimitId;

    /**
     * 详情信息
     */
    @TableField("`desc`")
    private String desc;


    @TableField("create_per")
    private Integer createPer;

    @TableField("tenant_id")
    private Integer tenantId;
    /**
     * 创建用户
     */
    @TableField(exist=false)
    private String createPerName;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private Date updateTime;

    /**
     * 更新更新人
     */
    @TableField("update_per")
    private Long updatePer;

    /**
     * 更新更新人名称
     */
    @TableField(exist=false)
    private String updatePerName;


    @ApiModelProperty(value = "字段列表")
    @TableField(exist=false)
    private List<TableFieldInfo> tableFieldInfos;

    @TableField("table_level_id")
    private Integer tableLevelId;


    @TableField("rows_num")
    private Long rowsNum;

    @TableField("total_size")
    private Double totalSize;
    @TableField(exist=false)
    private String totalSizeStr;

    @TableField("last_count_time")
    private Date lastCountTime;


    @TableField("table_mask_open")
    private Integer tableMaskOpen;

    /**
     * 存储引擎 1 hive  2 kudu
     */
    @TableField("store_engine")
    private Integer storeEngine;
    /**
     * 类目id
     */
    @TableField(exist=false)
    private Set<Integer> categoryIds;
    /**
     * 主题id
     */
    @TableField(exist=false)
    private Set<Integer> subjectIds;
    /**
     * 生命周期
     */
    @TableField(value = "life_cycle",strategy = FieldStrategy.IGNORED)
    private Integer lifeCycle;
    /**
     * 是否  0 长期  1 长期
     */
    @TableField("long_life_flag")
    private Integer longLifeFlag;

    @TableField("table_mask_white_list")
    private String tableMaskWhiteList;

    /**
     * 表密级信息
     */
    @TableField(exist=false)
    private String levelName;
    @TableField(exist=false)
    private Integer sourceId;

    @TableField("security_data_level")
    private String securityDataLevel;

    @TableField(exist=false)
    private String projectName;

    @TableField(exist=false)
    private Integer tableType;
    @TableField(exist=false)
    private Integer applyStatus;

    @TableField(exist=false)
    private Integer applyId;

    /**
     * 审批人
     */
    @TableField(exist=false)
    private String approveUser;

    @TableField(exist=false)
    private Long approveUserId;

    /**
     * 申请人
     */
    @TableField(exist=false)
    private String applyUser;

    @TableField(exist=false)
    private Long applyUserId;

    /**
     * 回收理由
     */
    @TableField(exist=false)
    private String rollbackReason;
    /**
     * 有效截止日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Date effectiveDeadline;

    /**
     * 和修改创建表时候 给固定角色授权
     */
    @TableField(exist=false)
    private Long roleId;

    //读取热度
    @TableField(exist=false)
    private Integer viewNum;

    //引用热度
    @TableField(exist=false)
    private Integer quoteNum;
    // 元数据id
    @TableField(exist=false)
    private Integer metaId;
    //主题信息
    @TableField(exist=false)
    private String subjectName;
    //主题域
    @TableField(exist=false)
    private String subjectArea;

    //元数据表的表id
    @TableField(exist=false)
    private Integer collectionTableId;

    public Integer getStoreType() {
        // 1离线表  2 实时表
        return 1;
    }
    //离线表关联的目录id
    @TableField(exist=false)
    private List<String> cateGoryIdsList;
}
